#ifndef SELECTRECT_H
#define SELECTRECT_H

#include <QRectF>
#include "selectrect.h"

class SelectRect
{
private:
    QRectF m_rectangle;
    int m_role;
    int m_order;
    double m_scale; // l'échelle
    bool m_optim; // doit-on nettoyer l'image ?
    int m_contrast; // le contraste de l'image (1..255)

public:
    inline SelectRect () { clear (); }

    inline SelectRect (const SelectRect& other)
    {
        m_rectangle = other.m_rectangle;
        m_role = other.m_role;
        m_order = other.m_order;
        m_scale = other.m_scale; // l'échelle
        m_optim = other.m_optim; // doit-on nettoyer l'image ?
        m_contrast = other.m_contrast; // le contraste de l'image (1..255)
    }

    inline SelectRect (const QRectF& r,
                const int rol,
                const int ord,
                const double s,
                const bool opt,
                const int contr)
    {
        setRectangle (r);
        setRole (rol);
        setOrder (ord);
        setScale (s);
        setOptim (opt);
        setContrast (contr);
    }

    ~SelectRect () {}

    inline void clear ()
    {
        setRectangle (QRectF ());
        setRole (0);
        setOrder (0);
        setScale (1.0);
        setOptim (false);
        setContrast (qRound (255.0/2.0));
    }

    inline bool operator == (const SelectRect &other) {
        if (role () != 0) {
            if (role () == other.role ())
                return rectangle () == other.rectangle ();
            else
                return false;
        }
        else
            return rectangle () == other.rectangle ()
                    && role () == other.role ()
                    && order () == other.order ()
                    && scale () == other.scale ()
                    && optim () == other.optim ()
                    && contrast () == other.contrast ();
    }
    inline bool operator != (const SelectRect& other) { return ! (operator == (other)); }


    inline const QRectF &rectangle () const { return m_rectangle; }
    inline int role () const { return m_role; }
    inline int order () const { return m_order; }
    inline double scale () const { return m_scale; }
    inline bool optim () const { return m_optim; }
    inline int contrast () const { return m_contrast; }

    inline void setRectangle (const QRectF &rect) { m_rectangle = rect; }
    inline void setRole (const int role) { m_role = role; }
    inline void setOrder (const int order) { m_order = order; }
    inline void setScale (const double s) { m_scale = s; }
    inline void setOptim (const bool b) { m_optim = b; }
    inline void setContrast (const int c) { m_contrast = c; }

};

#endif // SELECTRECT_H
